<?php
// No direct access
defined('_JEXEC') or die;

class PricerContractorsHelper {

	public static $extension = 'com_pricercontractors';

	public static function addSubmenu($vName) {
		JSubMenuHelper::addEntry(
			JText::_('COM_PRICER_SUBMENU_CONTRACTORS'),
			'index.php?option=com_pricercontractors&view=contractors',
			$vName == 'contractors');
		JSubMenuHelper::addEntry(
			JText::_('COM_PRICER_SUBMENU_CATEGORIES'),
			'index.php?option=com_categories&extension=com_pricercontractors',
			$vName == 'categories');
		JSubMenuHelper::addEntry(
			JText::_('COM_PRICER_SUBMENU_LEGAL_ENTITIES'),
			'index.php?option=com_pricercontractors&view=legalentities',
			$vName == 'legalentities');
	}

	public static function getActions($categoryId = 0, $id = 0) {

		// Инициализируем переменные
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($id) && empty($categoryId)) {
			$assetName = 'com_pricercontractors';
		}

		elseif (empty($id)) {
			$assetName = 'com_pricercontractors.category.'.(int) $categoryId;
		}

		else {
			$assetName = 'com_pricercontractors.contractor.'.(int) $id;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
}
